#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>

int main() {
	int sock_fd = socket(AF_INET, SOCK_STREAM, 0);
	if(sock_fd < 0) {
		perror("socket");
		exit(1);
	}
	struct sockaddr_in serveraddr, clientaddr;
	serveraddr.sin_family = AF_INET;
	serveraddr.sin_addr.s_addr = htonl(INADDR_ANY);
	serveraddr.sin_port = htons(8000);

	
	if (bind(sock_fd, (struct sockaddr *)&serveraddr, sizeof(serveraddr)) < 0) {
		perror("bind");
		close(sock_fd);
		exit(1);
	}
	
	sleep(1);	

	clientaddr.sin_family = AF_INET;
	clientaddr.sin_addr.s_addr = inet_addr("127.0.0.1");
	clientaddr.sin_port = htons(8001);

	int ret = connect(sock_fd, (struct sockaddr *)&clientaddr, sizeof(clientaddr));
	if (ret < 0) {
		perror("connect");
		close(sock_fd);
		exit(1);
	}

	while(1);


	return 0;
}
